package com.ly.hotel.spainterface.pp.view;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.widget.ImageView;

import com.ly.hotel.R;
import com.ly.hotel.common.MyApplication;
import com.ly.hotel.util.ImageUtil;

/**
 * Created by mo on 2018/5/23.
 */

public class TechnicianImageDialog extends Dialog {

    private String technicianNo;
    private Context context;
    private int rod = 0;
    private String imageSrc;
    private boolean isWholeUrl;

    public TechnicianImageDialog(Context context, int themeResId) {
        super(context, themeResId);
        this.context = context;
        rod = context.getResources().getDimensionPixelSize(R.dimen.px6);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.technician_iamge_dialog);
        initView();
    }

    private void initView() {
        ImageView bigTechnicianImage = findViewById(R.id.big_technician_image);
        String imageUrl = "";
        if (!TextUtils.isEmpty(imageSrc)) {
            if (isWholeUrl) {
                imageUrl = imageSrc;
            } else {
                imageUrl = imageSrc + technicianNo + ".jpg";
            }
        } else {
            imageUrl = MyApplication.getHostResUrl() + "/upload/interface/technician/pic/" + technicianNo + ".jpg";
        }
        ImageUtil.displayImage_Round(context, imageUrl, bigTechnicianImage, rod);
    }

    public void setTechnicianNo(String technicianNo) {
        this.technicianNo = technicianNo;
    }

    public void setImageSrc(String imageSrc) {
        this.imageSrc = imageSrc;
    }

    public void setWholeUrl(boolean wholeUrl) {
        isWholeUrl = wholeUrl;
    }
}
